﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.Organization.Read.API.Application.Command.FieldSettingCommand;
using S.Organization.Read.API.Application.Command.SheepFarmCommand;

namespace S.Organization.Read.API.Controllers
{
    /// <summary>
    /// 栏位
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class FieldController : ControllerBase
    {
        private readonly IMediator _mediator;

        public FieldController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> HandleGetSheepFarm([FromQuery] GetFieldSettingCommand request, CancellationToken cancellationToken)
        {
            return Ok(await _mediator.Send(request));
        }

        /// <summary>
        /// 获取数据分页
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult>GetSheepFarm([FromQuery] ShowFieldSettingCommand request, CancellationToken cancellationToken)
        {
            return Ok(await _mediator.Send(request));
        }

    }
}
